﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
//using System.Web.DynamicData;
using OA.Model;
using OA.Model.MyAttribute;
using OA.Core;

namespace OA.Model
{
    [Table("Vote")]
    public class Vote : BaseInfo
    {
        public int Status { get; set; }

        [MaxLength(20)]
        [Display(Name = "主题")]
        [Tag(TagEnum.Text, "required", "主题", 2, 20)]
        [Required]
        public string Title { get; set; }

        [Display(Name = "开始时间")]
        [Tag(TagEnum.DateTime, "required", "开始时间", 2, 20)]
        public DateTime StartTime { get; set; }

        [Display(Name = "结束时间")]
        [Tag(TagEnum.DateTime, "required", "结束时间", 2, 20)]
        public DateTime EndTime { get; set; }

        [MaxLength(1000)]
        [Display(Name = "描述")]
        [Tag(TagEnum.TextArea, "", "描述", 2, 20)]
        public string Description { get; set; }

        public string VoteItemContent { get; set; }

        

    }

    public class SimpleVote : SimpleInfo
    {
        public string Title { get; set; }

        public DateTime StartTime { get; set; }

        public DateTime EndTime { get; set; }

        public static Expression<Func<Vote, SimpleVote>> Map = m => new SimpleVote()
        {
            ID = m.ID,
            Title = m.Title,
            StartTime=m.StartTime,
            EndTime=m.EndTime
        };
    }

    public enum VoteItemType
    {
        [Description("单选")]
        One = 1,

        [Description("多选")]
        Two = 2,

        [Description("问答")]
        Three = 3
    }

    public class VoteItem 
    {
        public int ID { get; set; }

        public int Status { get; set; }

        /// <summary>
        /// 1:单选 2:多选 3:问答
        /// </summary>
        [Tag(TagEnum.Select, typeof(VoteItemType),"",true)]
        public int Type { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        [MaxLength(500)]
        public string Title { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        public string ItemContent { get; set; }

    }

    public class ApiVoteItem
    {

        public int ID { get; set; }

         
        /// <summary>
        /// 1:单选 2:多选 3:问答
        /// </summary>
        [Tag(TagEnum.Select, typeof(VoteItemType), "", true)]
        public int Type { get; set; }

        public string TypeName { get { return MyEnum.GetEnumNameByValue(this.Type, typeof(VoteItemType)); } }

        /// <summary>
        /// 标题
        /// </summary>
        [MaxLength(500)]
        public string Title { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        public List<VoteOptionItem> OptionItem { get; set; }

        public string Answer { get; set; }

    }

    public class VoteOptionItem
    {
        /// <summary>
        /// A B  
        /// </summary>
        public string Key { get; set; }

        public string Option { get; set; }

        public bool IsSelect { get; set; }

        public int Index { get; set; }
    }

   

}
